﻿using System;
using System.Globalization;

namespace StockholmsStad.Windows.UI.Modules.Maintenance.Converters
{
    public class MinisterToComboBoxItemConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType != typeof(string))
                throw new InvalidOperationException("The target must be a string");

            if (value != null)
            {
                var dateTime = (DateTime)value;
                return dateTime.ToString("yyyy-MM-dd");
            }
            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion

    }
}
